package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Account  string
	Password string
	NickName string
}

func (u *User) GetUserByID(userId int64) error {
	return DB.Where("id=?", userId).Limit(1).Find(&u).Error
}

type Orders struct {
	gorm.Model
	UserId  int64   //用户ID
	GoodsId int64   //商品ID
	OrderSn string  //订单编号
	Num     int64   //数量
	Total   float32 //总价
	Status  int64   `gorm:"type:int;default:1;comment:默认1 为待支付 2为待收获 3为已完成"`
}

func (o *Orders) CreateOrders() error {
	return DB.Create(&o).Error
}
